package com.bookhouse.service.impl;

import com.bookhouse.dao.BaseDao;
import com.bookhouse.service.BaseService;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;
import java.util.Set;

/**
 * Created by CiusCheung on 16/4/8.
 */
@Transactional
public abstract class BaseServiceImpl<T> implements BaseService<T>{

    protected abstract BaseDao<T> getDao();

    @Override
    public T get(Class<T> entityClazz, Serializable id) {
        return getDao().get(entityClazz, id);
    }

    @Override
    public List<T> findAllList(Class<T> entityClazz) {
        return getDao().findAllList(entityClazz);
    }

    @Override
    public Set<T> findAllSet(Class<T> entityClazz) {
        return getDao().findAllSet(entityClazz);
    }

    @Override
    public void delete(Class<T> entityClazz, Serializable id) {
        getDao().delete(entityClazz,id);
    }

    @Override
    public void save(T entity) {
        getDao().save(entity);
    }

    @Override
    public void update(T entity) {
        getDao().update(entity);
    }

    @Override
    public List<T> find(String sql){
        return getDao().find(sql);
    }

    @Override
    public long findCount(Class<T> entityClazz){
        return getDao().findCount(entityClazz);
    }

}
